import { commonParams } from './config';
import axios from 'axios';

// 获取某个歌曲的vkey
export function getSongVkey (songmid) {
    // let paramStr ='{"req":{"module":"CDN.SrfCdnDispatchServer","method":"GetCdnDispatch","param":{"guid":"1234351723","calltype":0,"userip":""}},"req_0":{"module":"vkey.GetVkeyServer","method":"CgiGetVkey","param":{"guid":"1224151323","songmid":["';
    // paramStr=paramStr+songmid;
    // let paramStr2='"],"songtype":[0],"uin":"2461958018","loginflag":1,"platform":"20"}},"comm":{"uin":2461958018,"format":"json","ct":24,"cv":0}}';
    // paramStr=paramStr+paramStr2;
    const paramStr = `{"req":{"module":"CDN.SrfCdnDispatchServer","method":"GetCdnDispatch","param":{"guid":"1234351723","calltype":0,"userip":""}},"req_0":{"module":"vkey.GetVkeyServer","method":"CgiGetVkey","param":{"guid":"1224151323","songmid":["${songmid}"],"songtype":[0],"uin":"2461958018","loginflag":1,"platform":"20"}},"comm":{"uin":2461958018,"format":"json","ct":24,"cv":0}}`;
    return axios.get('/api/geturl', {
    params: paramStr
  });
}

// 获取歌曲的url
export function getSongURL (songmid, vkey) {
  return `http://dl.stream.qqmusic.qq.com/C400${songmid}.m4a?vkey=${vkey}&guid=3009522126&uin=0&fromtag=66`;
}

// 获取歌曲的歌词
export function getLyrics (id) {
  let data = Object.assign({}, commonParams, {
    nobase64: 1,
    musicid: id,
    g_tk: 485638389,
    hostUin: 0,
    notice: 0,
    platform: 'yqq',
    needNewCode: 0
  });
  return axios.get('/api/lyrics', {
    params: data
  });
}
